﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Db;
using Db.Tool;

namespace Db
{
    public class DbTool
    {
        ITool tool = null;

        public DbTool()
        {
            switch (DbHelper.dbProviderName)
            {
                case "System.Data.SQLite": tool = new SQLiteTool(); break;
                case "System.Data.SqlClient": tool = new SQLTool(); break;
                default: new Exception("该数据库类型还没有对应的方法"); break;
            }
        }

        /// <summary>
        ///返回数据库表列表名
        /// </summary>
        /// <returns>K:表名 v:主键</returns>
        public Dictionary<string, string> GetTableList()
        {
            Func<DbHelper, yq.CaCheRefresh, Dictionary<string, string>> trm = (cn, refresh) =>
            {
                return tool.GetTableList(cn);
            };


            return DBTrans.DoTrans(trm); ;
        }

    }
}
